package com.chuanyin.mp3player.commons;

import java.util.ArrayList;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.Window;

import com.chuanyin.mp3player.process.AllSongsProcess;
import com.chuanyin.mp3player.process.LastPlayedProcess;
import com.chuanyin.mp3player.process.MainOptionsProcess;
import com.chuanyin.mp3player.process.OnlineSongsProcess;
import com.chuanyin.mp3player.process.SingersProcess;
import com.chuanyin.mp3player.storage.PlayerApp;
import com.chuanyin.mp3player.storage.Song;
import com.chuanyin.mp3player.storage.SystemDBService;

public class AndroidUtil {
	
	
	public static MainOptionsProcess getMainOptionProcess(Context ctx){
		PlayerApp app = (PlayerApp) ctx.getApplicationContext();
		return app.getMainOptionProcess();
	}
	
	public static void setMainOptionProcess(Context ctx,MainOptionsProcess mainOptionProcess){
		PlayerApp app = (PlayerApp) ctx.getApplicationContext();
		app.setMainOptionProcess(mainOptionProcess);
	}
	
	public static AllSongsProcess getAllSongsProcess(Context ctx){
		PlayerApp app = (PlayerApp) ctx.getApplicationContext();
		return app.getAllSongsProcess();
	}
	
	public static void setAllSongsProcess(Context ctx,AllSongsProcess allSongsProcess){
		PlayerApp app = (PlayerApp) ctx.getApplicationContext();
		app.setAllSongsProcess(allSongsProcess);
	}
	
	public static void setSingersProcess(Context ctx,SingersProcess singersProcess){
		PlayerApp app = (PlayerApp) ctx.getApplicationContext();
		app.setSingerProcess(singersProcess);
	}
	
	public static SingersProcess getSingersProcess(Context ctx){
		PlayerApp app = (PlayerApp) ctx.getApplicationContext();
		return app.getSingerProcess();
	}
	
	public static void setLastPlayedProcess(Context ctx,LastPlayedProcess lastPlayedProcess){
		PlayerApp app = (PlayerApp) ctx.getApplicationContext();
		app.setLastedPlayerProcess(lastPlayedProcess);
	}
	
	public static LastPlayedProcess  getLastPlayedProcess(Context ctx){
		PlayerApp app = (PlayerApp) ctx.getApplicationContext();
		return app.getLastedPlayerProcess();
	}
	
	public static ArrayList<Song> getSongsList(Context ctx){
		PlayerApp app = (PlayerApp) ctx.getApplicationContext();
		return app.getSongs();
	}
	public static void setSongsList(Context ctx,ArrayList<Song> songs){
		PlayerApp app = (PlayerApp) ctx.getApplicationContext();
		app.setSongs(songs);
	}
	
	public static OnlineSongsProcess getOnlineSongsProcess(Context ctx){
		PlayerApp app = (PlayerApp) ctx.getApplicationContext();
		return app.getOnlineSongsProcess();
	}
	
	public static void setOnlineSongsProcess(Context ctx,OnlineSongsProcess onlineSongsProcess){
		PlayerApp app = (PlayerApp) ctx.getApplicationContext();
		app.setOnlineSongsProcess(onlineSongsProcess);
	}
	
	public static void setSystemDBService(Context context,
			SystemDBService systemDBService)
	{
		PlayerApp app = (PlayerApp) context.getApplicationContext();
		app.setSystemDBService(systemDBService);
	}

	public static SystemDBService getSystemDBService(Context context)
	{
		PlayerApp app = (PlayerApp) context.getApplicationContext();
		return app.getSystemDBService();
	}
	
	public static void changeBackground(Window window,String fileName)
	{
		if (fileName != null)
		{
			window.setBackgroundDrawable(Drawable.createFromPath(fileName));
		}
		else
		{
			window.setBackgroundDrawableResource(com.chuanyin.mp3player.R.drawable.bg);
		}

	}

	}
